package com.feihao.calendarTest;

import java.util.Calendar;

public class demo1 {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();

        /*int month = c.get(Calendar.MONTH);
        System.out.println(month);


        c.set(2021,4,5);

        System.out.println(c.get(Calendar.MONTH));*/

        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH) + 1;  // 0 - 11 -> 1-12
        int day = c.get(Calendar.DAY_OF_MONTH);
        System.out.println("现在是" + year + "年" + month + "月" + day + "日");
        int hour = c.get(Calendar.HOUR);
        int minute = c.get(Calendar.MINUTE);
        int second = c.get(Calendar.SECOND);
        System.out.println(hour + "时" + minute + "分" + second + "秒");



        c.set(2008, 7, 8);
        year = c.get(Calendar.YEAR);
        month = c.get(Calendar.MONTH) + 1;  // 0 - 11 -> 1-12
        day = c.get(Calendar.DAY_OF_MONTH);
        System.out.println("现在是" + year + "年" + month + "月" + day + "日");

    }
}
